﻿/*
 * Author:xmfdsh 11届网络部--邓世豪
 * DataTime：2014-6-9
 * Copyright © 2014 大学生勤工助学服务队 Powered by xmfdsh & 四小狼工作室.
 * 版权所有，违者必究
 */
using Common.Attributes;
using QGZX.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace QGZX.Logic.QGOA
{
    public class LoginController : Controller
    {
        #region 学生用户登录页面 + ActionResult Index()
        /// <summary>
        /// 学生用户登录页面
        /// </summary>
        /// <returns></returns>
        [Skip]
        public ActionResult Index()
        {
            MODEL.qgzx_config model = OperateContext.Current.BLLSession.Iqgzx_configBLL.GetListBy(x => x.SystemName != null).FirstOrDefault();
            ViewBag.configModel = model;
            return View();
        } 
        #endregion

        #region  Action 处理方法集合 + ActionResult Action()
        /// <summary>
        /// Action 处理方法集合
        /// </summary>
        /// <returns></returns>
        [Skip]
        public ActionResult Action()
        {
            string dowhat = Request["dowhat"];

            if (dowhat.Equals("login"))
            {
                string Number = Request["Name"];
                string Password = Request["Password"];

                MODEL.qgoa_user user = OperateContext.Current.BLLSession.Iqgoa_userBLL.GetListBy(x => x.Number == Number).FirstOrDefault();
                if (user != null)
                {
                    Session["user"] = user;
                    return OperateContext.Current.RedirectAjax("ok", "操作成功", null, "/QGOA/User/Index");
                    //写日志
                    //logBLL.CreateLog(user.Name, "登陆成功");
                }
                else
                {
                    return OperateContext.Current.RedirectAjax("err", "操作错误", null, "");
                }
                //return OperateContext.Current.RedirectAjax("err", "操作错误", null, "");
            }
            return OperateContext.Current.RedirectAjax("err", "操作错误", null, "");
        } 
        #endregion
    }
}
